<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>修改订单</title>
@foreach($config as $v)
<meta name="description" content="{{ $v->description }}" />
<meta name="keywords" content="{{ $v->keys }}" />
<title>{{ $v->title }}</title>
@endforeach
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta name="csrf-token" content="{{ csrf_token() }}">
<link href="{{asset('css/base.css')}}" rel="stylesheet" type="text/css"/>
<link href="{{asset('css/order.css')}}" type="text/css" rel="stylesheet" />
<script type="text/javascript" src='{{asset("ajax/jquery-1.8.3.min.js") }}'></script>
</head>
<body>
    <form action="" method="post" name="myform">
        <input type="hidden" name="_token" value="{{csrf_token()}}">
        <input type="hidden" name="_method" value="DELETE">
    </form>
<div class="o_h container">
    @foreach($config as $v)
	<h1 class="f_l oh_logo"><a href="/home"><img src="{{asset('uploads').'/'.$v->logo}}" alt="麦路客网上购物商城" /></a></h1><!--oh_logo end-->
    @endforeach
    <div class="f_r oh_mian">
		<div class="oh_dh">
			<div class="f_r l_bg"></div>
			<div class="f_r oh_dh_m"><a href="#">麦路客首页</a><span>|</span><a href="#">我的麦路客</a><span>|</span><a href="#">帮助中心</a></div>
			<div class="f_r r_bg"></div>
		</div><!--oh_dh end-->

		<div class="blank20"></div>

		<div class="flow_step">
			<ul>
				<li class="step_04">3.成功提交订单</li>
				<li class="step_10"></li>
				<li class="step_02">2.填写核对订单信息</li>
				<li class="step_08"></li>
				<li class="step_04">1.我的购物车</li>
				<li class="step_07"></li>
			</ul>
		</div><!--flow_step end-->
	</div><!--oh_mian end-->

	<div class="clear"></div>

</div><!--o_h end-->

<div class="content container">
	<div class="blank10"></div>
	<div class="dl_zc">
		<div class="dl_zc_title" style="margin-left:0px;">
			<h2 class="f_l">填写核对订单信息</h2><div class="rt_bg f_r"></div>
		</div><!--dl_zc_title end-->
		<div class="d_z_content">
			<div class="order">
				<div class="o_d_title">
					<h2 class="f_l">收货人信息</h2><span class="f_r"><a class="red set-info">修改</a></span>
				</div><!--o_d_title end-->

				<div class="address">
					<ul id="ulid">

                    </ul>
				</div><!--address end-->

				<div class="ytx info-con">
				<form method="post" action="" name="ready">
                    <input type='hidden' name='_token' value='{{ csrf_token() }}'>
                    <input type="hidden" name="uid" value="{{session()->get('homeuser')->id}}">
					<table>
						<tbody>
							<tr>
								<td width="76px" class="a-r"><span class="red">*</span>收货人：</td><td><input type="text" name="consignee" value="{{session()->get('homeuser')->realname}}" id="" class="input-text" size="38" /></td>
							</tr>
							<tr>
								<td class="a-r"><span class="red">*</span>地区：</td>
                                <td>
                                    <select name="province" id="cid">
                                        <option>--请选择--</option>
                                    </select>&nbsp;&nbsp;市：
                                    <select name="city">
                                        <option>--请选择--</option>
                                    </select>&nbsp;&nbsp;县/区：
                                    <select name="country">
                                        <option>--请选择--</option>
                                    </select>
                                </td>
							</tr>
							<tr>
								<td class="a-r"><span class="red">*</span>详细地址：</td><td><input type="text" placeholder="请输入详细地址" name="adddetail" id="" class="input-text" size="60" /></td>
							</tr>
							<tr>
								<td class="a-r"><span class="red">*</span>联系方式：</td><td><input value="" type="text" name="phone" id="" class="input-text" size="38" />&nbsp;&nbsp;用于接收发货通知短信及送货前确认</td>
							</tr>
							<tr>
								<td class="a-r">邮政编码：</td><td><input type="text" value="" name="code" id="" class="input-text" size="14" />&nbsp;&nbsp;有助于快速确定送货地址</td>
							</tr>
							<tr>
								<td></td><td height="50px"><a class="yellow" href="javascript:addad()">[添加到常用地址]</a></td>
							</tr>
						</tbody>
					</table>
                </form>
                <form method="post" action="" id="addata">
                    <input type='hidden' name='_token' value='{{ csrf_token() }}'>
                    <input type='hidden' name='_method' value='PUT'>
                    <input type="hidden" name="oid" value="{{$oid}}">
                    <div class="blank10"></div>
                    <div class="now_address">
                        <div class="now_address_t">
                            <h3 class="f_l">常用地址</h3>

                        </div><!--now_address_t end-->
                        <div class="now_address_l">
                            <ul>
                                @foreach($address as $v)
                                <li>
                                    <div class="f_l">
                                        <input type="radio" name="did" value="{{$v->id}}" id="rad1" />
                                        <label for="rad1"><strong>{{ $v->consignee }}</strong><span>{{ $v->province }}{{ $v->city }}{{ $v->country }}{{$v->adddetail}}</span></label>
                                    </div>

                                    <div class="f_r"><a href="javascript:doDel({{$v->id}})" class="red">[删除]</a></div>
                                </li>
                                @endforeach
                            </ul>
                        </div><!--now_address_l end-->
                    </div><!--now_address end-->
                    <table>
                        <tr>
                            <td></td><td><span class="red_button"><button style="width: 140px;" type="button" id="sub">保存收货人信息</button></span></td>
                        </tr>
                    </table>
                </form>
                    <script type="text/javascript">
                    function doDel(id)
                    {
                        if(confirm("确定删除该地址？")){
                            var form = document.myform;
                            form.action = "/home1/editaddress/"+id;
                            form.submit();
                        }
                    }
                    </script>
				</div>
			</div><!--order end-->
            <script type="text/javascript">
                function addad()
                {
                    var form = document.ready;
                    form.action = "/home1/editaddress";
                    form.submit();
                }
            </script>

			<div class="blank10"></div>

			<div class="order">
			<form method="post" action="" id="">
				<div class="o_d_title">
					<h2 class="f_l">支付方式</h2>
				</div><!--o_d_title end-->
				<div class="ytx"><p>支付宝-在线付款</p></div>
			</form>
			</div><!--order end-->

			<script language="javascript" src="js/jquery.checkboxes.js"></script>

			<script type="text/javascript">
			$(document).ready(function(){
				$('.set-info').bind('click',function(){
					var element = $(this).parents('.order');
					if(element.hasClass('switchable')){
						element.removeClass('switchable');
						this.innerHTML="修改";
					} else {
						element.addClass('switchable');
						this.innerHTML="关闭";
					}
					return false;
				});
			});
			</script>

			<div class="blank10"></div>

			<div class="cate_list">
			<form method="post" action="/home1/editorder/{{$oid}}">
                <input type='hidden' name='_token' value='{{ csrf_token() }}'>
                <input type="hidden" name="_method" value="PUT">
                <input type="hidden" name="uid" value="{{session()->get('homeuser')->id}}">
                <input type="hidden" name="total" value="{{$order['total']}}">
				<div class="cate_list_main">
					<table cellpadding="0" cellspacing="0" border="0" width="100%">
						<thead>
							<tr>
								<th>商品</th>
								<th>尺寸</th>
								<th>单价</th>
								<th>数量</th>
								<th>小计</th>
							</tr>
						</thead>
						<tbody>
							<tr>
								<td><a href="#">{{$order['gname']}}</a></td>
								<td>{{$order['size']}}</td>
								<td>&yen;{{$order['gprice']}}元</td>
								<td>{{$order['number']}}</td>
								<td>&yen;{{$order['total']}}元</td>
							</tr>
						</tbody>
						<tfoot>
							<tr>
								<td colspan="7" style="border:none;">
									<table cellpadding="0" cellspacing="0" border="0" width="100%">
										<tr>
											<td>产品数量总计：{{$order['number']}}件</td>
											<td>产品金额共计：&yen;{{$order['total']}}元</td>
										</tr>
										<tr>
											<td colspan="4">运费：&yen;0.0元</td>
										</tr>
										<tr>
											<td colspan="4"><span class="total red">您共需要为订单支付：&yen;{{$order['total']}}元</span></td>
										</tr>
									</table>
								</td>
							</tr>
						</tfoot>
					</table>
				</div><!--cate_list_main end-->

				<div class="blank20"></div>

				<div class="tj_info">
					<div class="f_r"><input type="image" src="images/tj_dd_botton.gif" value="" /></div>
					<p class="f_r">请核对以上信息，确认无误后点击“提交订单”</p>
				</div><!--tj_info end-->
                <span class="red_button"><button style="width: 140px;" type="submit">提交订单</button></span>
				<div class="blank20"></div>
			</form>
			</div><!--cate_list end-->
		</div><!--d_z_content end-->
	</div><!--dl_zc end-->

	<div class="blank10"></div>

</div><!--content end-->

<div class="footer container">
	<div class="service">
		<div class="cat_bg"></div>
		<div class="help_list clearfix">
			<dl>
				<dt>新手指南</dt>
				<dd><a href="help/index.html" target="_blank"><span>购物流程</span></a></dd>
				<dd><a href="help/account.html" target="_blank"><span>我的麦路客</span></a></dd>
				<dd><a href="help/common.html" target="_blank"><span>常见问题</span></a></dd>
				<dd><a href="register.html" target="_blank"><span>注册用户</span></a></dd>
				<dd><a href="forgot-password.html" target="_blank"><span>找回密码</span></a></dd>
			</dl>
			<dl>
				<dt>订单问题</dt>
				<dd><a href="help/order-status.html" target="_blank">订单状态</a></dd>
				<dd><a href="help/cancel-order.html" target="_blank">取消订单</a></dd>
				<dd><a href="help/not-order.html" target="_blank">未达订单</a></dd>
			</dl>
			<dl>
				<dt>会员积分</dt>
				<dd><a href="help/integral-rules.html" target="_blank">积分规则</a></dd>
				<dd><a href="help/integral.html" target="_blank">积分问题</a></dd>
				<dd><a href="help/exchange-integral.html" target="_blank">积分兑换</a></dd>
			</dl>
			<dl>
				<dt>如何付款/退款</dt>
				<dd><a href="help/payment.html" target="_blank">支付方式</a></dd>
				<dd><a href="help/wait-pay.html" target="_blank">支付等待</a></dd>
				<dd><a href="help/pay-issue.html" target="_blank">支付问题</a></dd>
				<dd><a href="help/refund.html" target="_blank">办理退款</a></dd>
				<dd><a href="help/invoice-system.html" target="_blank">发票制度</a></dd>
			</dl>
			<dl>
				<dt>配送和收费</dt>
				<dd><a href="help/time-range.html" target="_blank">配送时间</a></dd>
				<dd><a href="help/delivery-time.html" target="_blank">送达时间</a></dd>
				<dd><a href="help/inspection-sign.html" target="_blank">验货与签收</a></dd>
				<dd><a href="help/express.html" target="_blank">快递配送和收费</a></dd>
				<dd><a href="help/ems.html" target="_blank">EMS配送和收费</a></dd>
			</dl>
			<dl>
				<dt>售后服务</dt>
				<dd><a href="help/policy.html" target="_blank">退换货政策</a></dd>
				<dd><a href="help/apply-goods.html" target="_blank">如何办理退换货</a></dd>
			</dl>
		</div>
	</div><!--service end-->
	<div class="copyright">
		<a href="help/about.html" target="_blank">关于麦路客</a><span>|</span><a href="help/contact.html" target="_blank">联系麦路客</a><span>|</span><a href="help/job.html" target="_blank">加入麦路客</a><span>|</span><a href="sort.html" target="_blank">网站地图</a><span>|</span><a href="help/complainting.html" target="_blank">投诉与建议</a><span>|</span><a href="help/links.html" target="_blank">友情链接</a><br />
		Copyright&nbsp;&nbsp;©&nbsp;&nbsp;2009-2011&nbsp;&nbsp;<a title="麦路客商城" href="javascript:void(0)">www.mailuke.com</a>&nbsp;&nbsp;麦路客商城版权所有<span>|</span><a href="http://www.miibeian.gov.cn/" target="_blank">沪ICP备10031526号</a><br />
		<a href="#" target="_blank"><img src="images/beian.gif" width="128" height="47" alt="经营性网站备案中心" /></a><a href="#" target="_blank"><img src="images/trustA.gif" width="119" height="47" alt="A级-信用企业" /></a><a href="#" target="_blank"><img src="images/alipay.gif" width="123" height="40" alt="支付宝-特约商家" /></a>
	</div><!--copyright end-->
</div><!--footer end-->
</body>
<script type="text/javascript">
    var url = "{{ url('aja/get') }}";
    $.ajax({
        url:url,
        async:false,
        data:{upid:0},
        type:'get',
        dataType:'json',
        error:function()
        {
            alert('ajax请求失败');
        },
        success:function(data)
        {
            console.log(data);
            for (var i = 0; i < data.length; i++) {
                $('#cid').append("<option value='"+data[i].id+"'>"+data[i].name+"</option>");
            };
        }
    });

    $("select").live("change",function(){
        //先清除后面的select，再添加新的select
        var ob = $(this);
        if($(this).val() != '--请选择--'){
            var upid = $(this).val();
            $.ajax({
                url:'/aja/post',
                async:false,
                type:'post',
                data:{upid:upid},
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                dataType:'json',
                error:function()
                {
                    alert('ajax请求失败');
                },
                success:function(data)
                {
                    if(data.length>0){
                        var select = ob.next('select');
                        $(select).children('option').remove();
                        $(select).append("<option>--请选择--</option>");
                        for (var i = 0; i < data.length; i++) {
                            $(select).append("<option value='"+data[i].id+"'>"+data[i].name+"</option>");
                        };
                    }
                }
            });
        }
    });
    $("#sub").click(function(){
        var url = "{{ url('/home1/editorder1') }}";
        $.ajax({
            url:url,
            async:false,
            data:$('#addata').serialize(),
            type:'post',
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            },
            dataType:'json',
            error:function()
            {
                alert('ajax请求失败');
            },
            success:function(data)
            {
                $("#ulid li").remove();
                var add = eval(data);
                $("#ulid").append(
                    "<li><span>收货人: </span>"+add.consignee+" </li><li><span>地区：</span>"+add.province+add.city+add.country+" </li><li><span>收货地址：</span>"+add.adddetail+"</li><li><span>联系方式：</span>"+add.phone+"</li><li><span>邮政编码：</span>"+add.code+"</li>"
                )
            }
        });
    });
</script>
</html>
